//
//  YMHomeService.m
//  YMMedical
//
//  Created by y s on 2023/7/5.
//

#import "YMHomeService.h"
#import "YMNetwork.h"
#import "YMDeviceTools.h"

@implementation YMHomeService

//上报异常接口
+ (void)appOperateReportExWithExCondition:(NSString *)exCondition
                                imageFile:(NSString *)imageFile
                                 fileSize:(NSString *)fileSize
                                   tcTime:(NSInteger)tcTime
                               uploadTime:(NSInteger)uploadTime
                                  success:(void(^)(void))success
                                  failure:(void(^)(NSString *message))failure{
    
    NSString *url = [kBaseUrl stringByAppendingString:@"/appOperate/reportEx"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[YMDeviceTools phoneModel] forKey:@"phoneModel"];
    [dict setValue:[YMDeviceTools phoneVersion] forKey:@"systemVersion"];
    [dict setValue:@"Apple" forKey:@"mobileBrand"];
    [dict setValue:@"dng" forKey:@"imageFormat"];
    [dict setValue:[SDataUtil stringOf:imageFile valid:@""] forKey:@"imageFile"];
    [dict setValue:@(tcTime) forKey:@"tcTime"];
    [dict setValue:@(uploadTime) forKey:@"uploadTime"];
    [dict setValue:fileSize forKey:@"fileSize"];
    [dict setValue:[SDataUtil stringOf:exCondition valid:@""] forKey:@"exCondition"];
    [dict setValue:@(1) forKey:@"dngState"];
    [dict setValue:@(1) forKey:@"rawState"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"] valid:0];
        if (code == 200){
            if (success){
                success();
            }
        }else{
            NSString *messge = [SDataUtil stringOf:data[@"msg"] valid:@"操作失败!"];
            if (failure){
                failure(messge);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(@"操作失败!");
        }
    }];
    
}


//segement 类型
+ (void)requestHomeSegementDataWithSuccess:(void(^)(NSArray *arrData))success
                                   failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"4a8b2701a8c14cf486805aead608ac0e"forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    [dict setValue:@0 forKey:@"isasc"];
    [dict setValue:@"by4aahapyxw1kvwb" forKey:@"sortid"];
    NSString *languageStr = [YMLanguageUtil isEnglish] ? @"76329d9d-b7d8-4306-82a6-9933f2a5e4b3":@"f8665d63-dc7f-4047-919f-b201ddadde05";
    [dict setValue:@[@{@"key":@"2vygl9fewacmgfww",
                       @"value":@"5e1e309a-abaf-45f2-a030-4b20e42a664f"},
                     @{@"key":@"sjxfveecowhxayym",
                       @"value":languageStr}] forKey:@"filters"];
    
    
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            NSArray *arrTemp = [SDataUtil arrayOf:dict[@"data"]];
            if (success){
                success(arrTemp);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:@"数据加载失败，请稍后重试"];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//banner 接口
+ (void)requestHomeItemInforWithSegementID:(NSString *)segementId
                                   success:(void(^)(NSArray *arrData))success
                                   failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"0f078bd3ef0946548f6e18b1f245f8c3"forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    [dict setValue:@1 forKey:@"isasc"];
    [dict setValue:@"wfwx0dlcvkpojft1" forKey:@"sortid"];
    NSString *languageStr = [YMLanguageUtil isEnglish] ? @"439d966f-54f5-42f0-94ad-f4df2801701a":@"1a36aa83-fec3-40c6-82e7-f5256dd23ca0";
    [dict setValue:@[@{@"key":@"jysnwnlyigidwpaf",
                       @"value":[SDataUtil stringOf:segementId valid:@""]},
                     @{@"key":@"gwkora0c5jwdubgf",
                       @"value":@"9c6bbabb-d61b-43e8-936f-6d8330b76b85"},
                     @{@"key":@"zxrqekxhvs1pdyik",
                       @"value":languageStr}] forKey:@"filters"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            NSArray *arrTemp = [SDataUtil arrayOf:dict[@"data"]];
            if (success){
                success(arrTemp);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//引导图
+ (void)requestAppGuideDataSuccess:(void(^)(NSArray *arrData,NSString *idStr))success
                           failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"18f72e99181143ad88d21716e1a25583"forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    
    NSString *languageStr = [YMLanguageUtil isEnglish] ? @"e697063d-b644-4e60-add8-91b793d2ad04":@"cee4177d-9923-4d4e-9a90-95edeaea7b0f";
    [dict setValue:@[@{@"key":@"xagdpk3r9sggqyuw",
                       @"value":languageStr}] forKey:@"filters"];
    
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            NSArray *arrTemp = [[NSArray alloc] init];
            NSString *idStr = @"";
            if (dict != nil){
                NSArray *arrData = [SDataUtil arrayOf:dict[@"data"]];
                if (arrData != nil && arrData.count > 0){
                    NSDictionary *dictData = [SDataUtil dictOf:arrData.firstObject];
                    arrTemp = [SDataUtil arrayOf:dictData[@"sdxltcmsgmmj1csv"]];
                    idStr = [SDataUtil stringOf:dictData[@"id"] valid:@""];
                }
            }
            
            if (success){
                success(arrTemp,idStr);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//操作视频
+ (void)requestHomeOperationVideoListData:(NSString *)idStr
                                   pageNo:(NSInteger)pageNo
                                  success:(void(^)(NSArray *arrData))success
                                  failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"82701bfc08714ac8a18e4a7507deae11"forKey:@"formheaduuid"];
    [dict setValue:@1 forKey:@"needpage"];
    [dict setValue:@(pageNo) forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    
    NSString *languageStr = [YMLanguageUtil isEnglish] ? @"98bde949-f24c-46d4-9913-dac0fa903121":@"f7cace96-2cb5-4873-b316-389c2522969e";
    [dict setValue:@[@{@"key":@"vnmzmquyysauypev",
                       @"value":[SDataUtil stringOf:idStr valid:@""]},
                       @{@"key":@"dzehvyavob24gjg2",
                       @"value":languageStr}] forKey:@"filters"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            NSArray *arrTemp = [[NSArray alloc] init];
            if (dict != nil){
                arrTemp = [SDataUtil arrayOf:dict[@"data"]];
            }
            if (success){
                success(arrTemp);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//查询账号 是否添加了设备
+ (void)requestHomeHadAddDeviceDataSuccess:(void(^)(BOOL hadDevice,NSArray *arrDevice))success
                                   failure:(void(^)(NSString *message))failure{

    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"2582bc4c14914246807a26886f46dd0e" forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    [dict setValue:@"created_at" forKey:@"sortid"];
    [dict setValue:@1 forKey:@"isasc"];
    
    NSMutableDictionary *dictField = [[NSMutableDictionary alloc] init];
    [dictField setValue:@"ope0wk2ysioftswt" forKey:@"key"];
    [dictField setValue:[YMMyModel shared].userId forKey:@"value"];
    [dict setValue:@[dictField] forKey:@"filters"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            BOOL hadDevice = NO;
            NSArray *arrDevice = [[NSArray alloc] init];
            if (dict != nil){
                arrDevice = [SDataUtil arrayOf:dict[@"data"]];
                hadDevice = arrDevice.count>0 ? YES:NO;
            }
            NSMutableArray *arrM = [[NSMutableArray alloc] init];
            if (arrDevice.count > 0){
                for (int i = 0; i < arrDevice.count; i++) {
                    NSDictionary *dictTemp = [SDataUtil dictOf:arrDevice[i]];
                    NSMutableDictionary *dictM = [[NSMutableDictionary alloc] initWithDictionary:dictTemp];
                    NSString *name = KLanguage(@"device_txt");
                    NSString *snStr = [SDataUtil stringOf:dictTemp[@"bhmohipntdlpc61m"] valid:@""];
                    if (i+1 < 10){
                        name = [NSString stringWithFormat:@"%@0%d",KLanguage(@"device_txt"),i+1];
                    }else{
                        name = [NSString stringWithFormat:@"%@%d",KLanguage(@"device_txt"),i+1];
                    }
                    if (snStr != nil && snStr.length > 7){
                        name = [name stringByAppendingFormat:@"(%@)",[snStr substringFromIndex:snStr.length-7]];
                    }else{
                        name = [name stringByAppendingFormat:@"(%@)",snStr];
                    }
                    [dictM setValue:name forKey:@"lh00tcgkbbqpj185"];
                    [arrM addObject:[dictM copy]];
                }
            }
            if (success){
                success(hadDevice,arrM);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}
//效验该设备是否已添加
+ (void)requestHomeCheckHadDeviceDataWithSN:(NSString *)snCode
                                    success:(void(^)(BOOL hadDevice))success
                                    failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"2582bc4c14914246807a26886f46dd0e" forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    
    NSMutableDictionary *dictField1 = [[NSMutableDictionary alloc] init];
    [dictField1 setValue:@"bhmohipntdlpc61m" forKey:@"key"];
    [dictField1 setValue:[SDataUtil stringOf:snCode valid:@""] forKey:@"value"];
    
    NSMutableDictionary *dictField2 = [[NSMutableDictionary alloc] init];
    [dictField2 setValue:@"ope0wk2ysioftswt" forKey:@"key"];
    [dictField2 setValue:[YMMyModel shared].userId forKey:@"value"];
    
    [dict setValue:@[dictField1,dictField2] forKey:@"filters"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            BOOL hadDevice = NO;
            if (dict != nil){
                NSArray *arrTemp = [SDataUtil arrayOf:dict[@"data"]];
                hadDevice = arrTemp.count>0 ? YES:NO;
            }
            if (success){
                success(hadDevice);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//查询 设备是否存在
+ (void)requestHomeDeviceIsTrueDataWithSn:(NSString *)snCode
                                  success:(void(^)(BOOL isTrue,NSDictionary *dictInfor))success
                                  failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/getFormList"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"f5c3335196184797bb2c964d090e4165" forKey:@"formheaduuid"];
    [dict setValue:@0 forKey:@"needpage"];
    [dict setValue:@1 forKey:@"page"];
    [dict setValue:@20 forKey:@"pagesize"];
    
    NSMutableDictionary *dictField = [[NSMutableDictionary alloc] init];
    [dictField setValue:@"tfsqjqvs0sp7qvh4" forKey:@"key"];
    [dictField setValue:[SDataUtil stringOf:snCode valid:@""] forKey:@"value"];
    [dict setValue:@[dictField] forKey:@"filters"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            BOOL isTrue = NO;
            NSDictionary *dictData = [[NSDictionary alloc] init];
            if (dict != nil){
                NSArray *arrTemp = [SDataUtil arrayOf:dict[@"data"]];
                if (arrTemp.count > 0){
                    dictData = [SDataUtil dictOf:arrTemp.firstObject];
                    if (dictData != nil && [dictData isKindOfClass:[NSDictionary class]]){
                        isTrue = YES;
                    }
                }
            }
            if (success){
                success(isTrue,dictData);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}
//添加 新设备
+ (void)requestHomeAddNewDeviceDataWithInfor:(NSDictionary *)dictInfor
                                     success:(void(^)(NSDictionary *dictInfor))success
                                     failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/addFormRow"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"2582bc4c14914246807a26886f46dd0e" forKey:@"formheaduuid"];
    
    NSMutableDictionary *dictField = [[NSMutableDictionary alloc] init];
    NSArray *imgArr = [SDataUtil arrayOf:dictInfor[@"xjgzqku0niynuevu"]];
    NSString *imgUrl = @"";
    if (imgArr.count > 0){
        NSDictionary *dictImg = [SDataUtil dictOf:imgArr.firstObject];
        imgUrl = [SDataUtil stringOf:dictImg[@"url"] valid:@""];
    }
    [dictField setValue:[SDataUtil stringOf:imgUrl valid:@""] forKey:@"1vbpshpsrd9ancnm"];
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"va5o2bbxwgzu1cmb"] valid:@""] forKey:@"3m3fta753ew75mom"];
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"id"] valid:@""] forKey:@"8vzt1b0ayishpetw"];
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"tfsqjqvs0sp7qvh4"] valid:@""] forKey:@"bhmohipntdlpc61m"];
    NSString *isAuthorized = [SDataUtil stringOf:dictInfor[@"ceb0lnznvqiuyvmb"] valid:@""];
    [dictField setValue:isAuthorized forKey:@"eozplztuhbbqpfon"];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    [dictField setValue:[dateFormatter stringFromDate:[NSDate date]] forKey:@"ikyjywsgjhhg2jmq"];
    
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"0ltcriv98n8wa1o8"] valid:@""] forKey:@"hxpbdrvv39dczmmf"];
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"9zd0k3hr1trcqesf"] valid:@""] forKey:@"jd6ugg6ktyckxbtp"];
    [dictField setValue:[SDataUtil stringOf:dictInfor[@"dvnobhxko5jl6y2c"] valid:@""] forKey:@"lh00tcgkbbqpj185"];
    
    [dictField setValue:[YMMyModel shared].userName forKey:@"lktelicb0kqxm5jj"];
    [dictField setValue:[YMMyModel shared].userId forKey:@"ope0wk2ysioftswt"];
    [dictField setValue:[YMMyModel shared].userPhone forKey:@"xoroodxlsn4riasa"];
    [dict setValue:dictField forKey:@"fields"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            NSDictionary *dict = [SDataUtil dictOf:data[@"result"]];
            if (success){
                success(dict);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//最近一次检测记录接口
+ (void)requestLatelyHealthRecordDetailsDetectionUserId:(NSString *)detectionUserId
                                            minorTermId:(NSString *)minorTermId
                                                success:(void(^)(NSDictionary *dictData))success
                                                failure:(void(^)(NSString *message))failure{
    
    NSString *url = [kBaseUrl stringByAppendingString:@"/app/user/getLatelyHealthRecordDetails"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[SDataUtil stringOf:[YMMyModel shared].userId valid:@""] forKey:@"tuoTuUserId"];
    [dict setValue:[SDataUtil stringOf:[YMMyModel shared].tuoTuToken valid:@""] forKey:@"tuoTuToken"];
    [dict setValue:[SDataUtil stringOf:detectionUserId valid:@""] forKey:@"detectionUserId"];
    [dict setValue:[SDataUtil stringOf:minorTermId valid:@""] forKey:@"minorTermId"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"]];
        if (code == 200){
            NSDictionary *dict = [SDataUtil dictOf:data[@"data"]];
            if (success){
                success(dict);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//健康档案根据账号获取被检测人和检测项目
+ (void)requestHomeHealthGetUsersAndItemsSuccess:(void(^)(NSArray *arrUser, NSArray *arrItem))success
                                         failure:(void(^)(NSString *message))failure{

    NSString *url = [kBaseUrl stringByAppendingString:@"/app/user/getHealthRecord"];
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[YMMyModel shared].tuoTuToken forKey:@"tuoTuToken"];
    [dict setValue:[YMMyModel shared].userId forKey:@"tuoTuUserId"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"]];
        if (code == 200){
            NSDictionary *dict = [SDataUtil dictOf:data[@"data"]];
            NSArray *userList = [SDataUtil arrayOf:dict[@"detectionInfoList"]];
            NSArray *itemList = [SDataUtil arrayOf:dict[@"projectInfoList"]];
            if (success){
                success(userList,itemList);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//健康档案日历
+ (void)requestHomeGetHealthCalendarRecordDetails:(NSString *)detectionUserId
                                      minorTermId:(NSString *)minorTermId
                                 collectStartDate:(NSString *)collectStartDate
                                   collectEndDate:(NSString *)collectEndDate
                                          success:(void(^)(NSArray *arrItem))success
                                          failure:(void(^)(NSString *message))failure{

    NSString *url = [kBaseUrl stringByAppendingString:@"/app/user/getHealthRecordDetails"];
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[YMMyModel shared].tuoTuToken forKey:@"tuoTuToken"];
    [dict setValue:[YMMyModel shared].userId forKey:@"tuoTuUserId"];
    [dict setValue:[SDataUtil stringOf:detectionUserId valid:@""] forKey:@"detectionUserId"];
    [dict setValue:[SDataUtil stringOf:minorTermId valid:@""] forKey:@"minorTermId"];
    [dict setValue:[SDataUtil stringOf:collectStartDate valid:@""] forKey:@"collectStartDate"];
    [dict setValue:[SDataUtil stringOf:collectEndDate valid:@""] forKey:@"collectEndDate"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"]];
        if (code == 200){
            NSArray *arrData = [SDataUtil arrayOf:data[@"data"]];
            if (success){
                success(arrData);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//删除健康档案接口
+ (void)requestHomeDeleteHealthReportWithId:(NSString *)idStr
                                    success:(void(^)(void))success
                                    failure:(void(^)(NSString *message))failure{
    
    NSString *url = [KTuoToUrl stringByAppendingString:@"/appsheets/sheetapi/deleteFormRow"];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:@"13aa4626c7014c1b93136c038019db8c" forKey:@"applicationid"];
    [dict setValue:@"2bc5b9902eee4a2699f44b689784f27e" forKey:@"formheaduuid"];
    [dict setValue:[SDataUtil stringOf:idStr valid:@""] forKey:@"rowid"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSString *status = [SDataUtil stringOf:data[@"status"]];
        if ([YMNetwork tuoTuSuccess:status]){
            if (success){
                success();
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"err_msg"] valid:@"删除失败"];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(@"删除失败");
        }
    }];
}

//健康档案详情
+ (void)requestHealthGetOneHealthRecordDetails:(NSString *)detectionId
                                       success:(void(^)(NSDictionary *dictData))success
                                       failure:(void(^)(NSString *message))failure{

    NSString *url = [kBaseUrl stringByAppendingString:@"/app/user/getOneHealthRecordDetails"];
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[YMMyModel shared].tuoTuToken forKey:@"tuoTuToken"];
    [dict setValue:[SDataUtil stringOf:detectionId valid:@""] forKey:@"detectionId"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"]];
        if (code == 200){
            NSDictionary *dict = [SDataUtil dictOf:data[@"data"]];
            if (success){
                success(dict);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}

//获取当前用户和被测人的近期检测项目，小类ID,大类ID
+ (void)requestHomegetOneMinorTermDetails:(NSString *)detectionId
                                  success:(void(^)(NSDictionary *dictData))success
                                  failure:(void(^)(NSString *message))failure{

    NSString *url = [kBaseUrl stringByAppendingString:@"/app/user/getOneMinorTermDetails"];
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setValue:[YMMyModel shared].tuoTuToken forKey:@"tuoTuToken"];
    [dict setValue:[YMMyModel shared].userId forKey:@"tuoTuUserId"];
    [dict setValue:[SDataUtil stringOf:detectionId valid:@""] forKey:@"detectionUserId"];
    
    [YMNetwork postWithUrl:url parameters:dict success:^(id  _Nonnull data) {
        NSInteger code = [SDataUtil intOf:data[@"code"]];
        if (code == 200){
            NSDictionary *dict = [SDataUtil dictOf:data[@"data"]];
            if (success){
                success(dict);
            }
        }else{
            NSString *msg = [SDataUtil stringOf:data[@"msg"] valid:KLanguage(@"net_error_later_retry")];
            if (failure){
                failure(msg);
            }
        }
    } failure:^(NSError * _Nonnull error) {
        if (failure){
            failure(KLanguage(@"net_error_later_retry"));
        }
    }];
}


@end
